<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 3//EN">
<HTML><HEAD>
		<TITLE>User's Guide - Conditional Execution: Route and Switch</TITLE>
		<META HTTP-EQUIV="keywords" CONTENT="GRAPHICS VISUALIZATION VISUAL PROGRAM DATA
MINING">
	<meta http-equiv="content-type" content="text/html;charset=ISO-8859-1">
</HEAD><BODY BGCOLOR="#FFFFFF" link="#00004b" vlink="#4b004b">
		<TABLE width=510 border=0 cellpadding=0 cellspacing=0>
			<TR>
				<TD><IMG SRC="../images/spacer.gif" WIDTH=80 HEIGHT=1></TD>
				<TD><IMG SRC="../images/spacer.gif" WIDTH=49 HEIGHT=1></TD>
				<TD><IMG SRC="../images/spacer.gif" WIDTH=24 HEIGHT=1></TD>
				<TD><IMG SRC="../images/spacer.gif" WIDTH=100 HEIGHT=1></TD>
				<TD><IMG SRC="../images/spacer.gif" WIDTH=3 HEIGHT=1></TD>
				<TD><IMG SRC="../images/spacer.gif" WIDTH=127 HEIGHT=1></TD>
				<TD><IMG SRC="../images/spacer.gif" WIDTH=6 HEIGHT=1></TD>
				<TD><IMG SRC="../images/spacer.gif" WIDTH=50 HEIGHT=1></TD>
				<TD><IMG SRC="../images/spacer.gif" WIDTH=71 HEIGHT=1></TD>
			</TR>
			<TR>
				<TD colspan=9><IMG src="../images/flcgh_01.gif" width=510 height=24 border="0" alt="OpenDX - Documentation"></TD>
			</TR>
			<TR>
				<TD colspan=2><A href="../allguide.htm"><IMG src="../images/flcgh_02.gif" width=129 height=25 border="0" alt="Full Contents"></A></TD>
				<TD colspan=3><A href="../qikguide.htm"><IMG src="../images/flcgh_03.gif" width=127 height=25 border="0" alt="QuickStart Guide"></A></TD>
				<TD><A href="../usrguide.htm"><B><IMG src="../images/flcgh_04d.gif" width=127 height=25 border="0" alt="User's Guide"></B></A></TD>
				<TD colspan=3><A href="../refguide.htm"><IMG src="../images/flcgh_05.gif" width=127 height=25 border="0" alt="User's Reference"></A></TD>
			</TR>
			<TR>
				<TD><A href="usrgu027.htm"><IMG src="../images/flcgh_06.gif" width=80 height=17 border="0" alt="Previous Page"></A></TD>
				<TD colspan=2><A href="usrgu029.htm"><IMG src="../images/flcgh_07.gif" width=73 height=17 border="0" alt="Next Page"></A></TD>
				<TD><A href="../usrguide.htm"><IMG src="../images/flcgh_08.gif" width=100 height=17 border="0" alt="Table of Contents"></A></TD>
				<TD colspan=3><A href="usrgu026.htm"><IMG src="../images/flcgh_09.gif" width=136 height=17 border="0" alt="Partial Table of Contents"></A></TD>
				<TD><A href="usrgu080.htm"><IMG src="../images/flcgh_10.gif" width=50 height=17 border="0" alt="Index"></A></TD>
				<TD><A href="../srchindx.htm"><IMG SRC="../images/flcgh_11.gif" width=71 height=17 border="0" alt="Search"></A></TD>
			</TR>
		</TABLE>
		<H2><A NAME="Header_97" ></A>4.3 Conditional Execution: Route and Switch</H2>
		<P>
Two of Data Explorer's mechanisms to control execution
flow through a visual program are the Switch and Route modules.
Switch allows you to switch between one or more inputs to
drive a single output;
Route is the inverse of
Switch, having a single input that can be routed to zero, one,
or more than one output.
Switch is typically used to choose between different paths in a
visualization program; for example, to pass an imported data field
through either the Glyph module or through Isosurface, depending
on user choice or characteristics of the data field itself.
Route is typically used to turn off portions of the visualization
program; for example, to turn off WriteImage or Export,
or to prevent rendering to an image window unless the user chooses
to create an image. Switch can be thought of as turning off
portions of the visual
program logically <I>above</I> Switch; Route can be thought of as
turning off portions of the visual program logically <I>below</I>
Route.
Note that while Route turns off modules that receive its unused
outputs, the Collect module is an exception: it runs even if some of
its inputs have been turned off by Route.

		<P>
<A HREF="usrgu027.htm#FIGXMODX2">Figure 19</A> shows an example of a Switch
module
controlling
whether an Isosurface or a MapToPlane is passed to Image.
In a simple data-flow execution model, this Switch
module will be executed when its inputs are available
(i.e., the results of the Isosurface and MapToPlane
modules, and the value of the selector). On
execution, the Switch module chooses whether to pass
the Isosurface or MapToPlane result to the output based
on the <TT><STRONG>selection</STRONG></TT> input to
Switch.
In the case of a pure data-flow
model both the Isosurface and MapToPlane modules execute
before the decision as to which will actually be used is
known.  Since both operations can be computationally
expensive, the execution of both of them is very inefficient.
<P>
Again, this problem is handled in Data Explorer
within the simple data-flow execution
module by an examination of the graph prior to execution.
If the <TT><STRONG>selection</STRONG></TT> value comes from an external
source (e.g., an interactor) and is known a priori,
the selection may be performed by a
simple transformation of the graph:
excising the Switch module altogether, and substituting arcs
from the selected source (either Isosurface or MapToPlane) to
each of the modules that, in the original network,
received the result of the Switch module.
This leaves the unselected module dangling. It and any of its ancestors
that are therefore made unnecessary will not be executed.

		<P>
A different procedure is used if the controlling
value is not static (e.g., if it is
determined elsewhere in the network), as shown in
<A HREF="#FIGXMODX3">Figure 20</A>.
Suppose either an isosurface or a set of vector glyphs is selected
depending on whether the data are scalar or vector. The determination
of the type of the data is made using the Inquire module (i.e.
at run time).
In this case, the selection value for the Switch module cannot be
determined before
the execution of the graph.
Instead, the graph must be evaluated in
stages: 1) determine the selection value, 2) determine the
necessary input to the Switch module and 3) evaluate the remainder of
the graph.
Since dynamic inputs may themselves be descended from other
non-static inputs (e.g., computed in the network), this process
may have to be performed repeatedly.

		<B><A NAME="FIGXMODX3" HREF="../usrguide.htm#FT_FIGXMODX3">Figure 20. Example
3</A></B><BR>
			<BR>
			<CENTER>
				<B><IMG SRC="../images/xmodf3.gif" ALT="Figure xmodf3 not
displayed."></B></CENTER>
		<P></P>
		<HR>
		<DIV align="center">
			<P><A href="../allguide.htm"><IMG src="../images/foot-fc.gif" width="94" height="18" border="0" alt="Full Contents"></A> <A href="../qikguide.htm"><IMG src="../images/foot-qs.gif" width="94" height="18" border="0" alt="QuickStart Guide"></A> <A href="../usrguide.htm"><IMG src="../images/foot-ug.gif" width="94" height="18" border="0" alt="User's Guide"></A> <A href="../refguide.htm"><IMG src="../images/foot-ur.gif" width="94" height="18" border="0" alt="User's Reference"></A></P>
		</DIV>
		<DIV align="center">
			<P><FONT size="-1">[ <A href="http://www.research.ibm.com/dx">OpenDX Home at IBM</A>&nbsp;|&nbsp;<A href="http://www.opendx.org/">OpenDX.org</A>&nbsp;] </FONT></P>
		</DIV>
		<P></P>
	</BODY></HTML>
